<?php

/*
|--------------------------------------------------------------------------
| 路由
|--------------------------------------------------------------------------
*/

#测试
Route::get('/test', 'TestController@index');
Route::post('/test', ['as' => 'test_upload', 'uses' => 'TestController@post']);
Route::get('/users/export', 'TestController@export');
Route::get('users', 'TestController@users');

####################################################
#登录，登出, 自动跳转, 密码重置
####################################################
Route::get('login', [
    'middleware' => 'guest', 'as' => 'login', 'uses' => 'loginController@loginGet']);
Route::post('login', [
    'middleware' => 'guest', 'uses' => 'SignController@in_post']);
Route::get('logout', [
    'middleware' => 'auth', 'as' => 'logout', 'uses' => 'loginController@logout']);
Route::controller('password', 'PasswordController');
Route::group(['middleware' => ['auth']], function()
{



    ####################################################
    #物品管理
    ####################################################

    Route::post('signup', [
        'as' => 'post_signup', 'uses' => 'SignController@up_post']);
    Route::get('commodities/houses', [
        'as' => 'commodities.houses', 'uses' => 'CommoditiesController@houses']);
    Route::get('commodities/flows', [
        'as' => 'commodities.flows', 'uses' => 'CommoditiesController@flows']);
    Route::get('commodities/done', [
        'as' => 'commodities.done', 'uses' => 'CommoditiesController@done']);


    Route::resource('commodities', 'CommoditiesController');
    #主页
    Route::get('/', [
        'as' => 'index', 'uses' => 'WelcomeController@index'] );

    ####################################################
    #学生的登录详情(包括资料修改，分数查询)
    ####################################################
    Route::get('stu/home', [
        'as' => 'stu_home', 'uses' => 'Stu\StudentController@home']);
    Route::get('stu/edit', [
        'as' => 'stu_edit', 'uses' => 'Stu\StudentController@edit']);
    Route::post('stu/update', [
        'as' => 'stu_update', 'uses' => 'Stu\StudentController@update']);

    ####################################################
    #管理员入口(增删改查，上传分数)
    ####################################################
    #查看成绩排名
    Route::get('admin/grade', [
        'as' => 'grade_list', 'uses' => 'Admin\GradeController@index']);
    #资源路由,学生的增删改查
    Route::resource('admin', 'Admin\AdminController');
    #上传分数
    Route::post('admin/upload_grade', [
        'as' => 'upload_grade', 'uses' => 'Admin\AdminController@upload_grade']);

    ####################################################
    #管理员下载上传学生名单，成绩表
    ####################################################
    #下载学生名单
    Route::get('download/stuList', [
        'as' => 'download_stu_list_excel', 'uses' => 'Admin\ExcelController@stuList']);
    Route::get('download/grade', [
        'as' => 'download_grade_list_excel', 'uses' => 'Admin\ExcelController@grade']);



    ####################################################
    #资源单板块
    ####################################################
    #资源单首页
    Route::get('sources/upload', [
        'middleware' => 'auth',
        'as' => 'upload', 'uses' => 'SourcesController@upload']);
    Route::post('sources/upload', [
        'middleware' => 'auth',
        'as' => 'upload', 'uses' => 'SourcesController@post_upload']);
    Route::get('sources/follow', [
        'as' => 'follow', 'uses' => 'SourcesController@follow']);
    Route::get('sources/{id}/download', [
        'as' => 'sources.download', 'uses' => 'SourcesController@download']);

    Route::resource('sources', 'SourcesController');

    Route::get('flows/{id}/launch', [
        'as' => 'flows.launch', 'uses' => 'FlowsController@launch']);
    Route::post('flows/{id}/update', [
        'as' => 'flows.updated', 'uses' => 'FlowsController@update']);
    Route::resource('flows', 'FlowsController');
    ####################################################
    #现货板块
    ####################################################
    #现货首页
    Route::get('supplies', [
        'as' => 'supply_index', 'uses' => 'SuppliesController@index']);


    ####################################################
    #注册
    ####################################################
    #注册首页
    Route::get('signin', [
        'as' => 'signin', 'uses' => 'SignController@sign_in']);


    Route::post('signup', [
        'as' => 'post_signup', 'uses' => 'SignController@up_post']);
    Route::get('signup', [
        'as' => 'signup', 'uses' => 'SignController@sign_up']);
    Route::get('signup/licence', [
        'as' => 'signup', 'uses' => 'SignController@licence']);


});